<template>
  <div>
    <goga-header title="充值记录">
      <div slot="left">
        <span @click="goBack">
          <icon symbol="back"> </icon>
        </span>
      </div>
    </goga-header>
    <div>
      <img v-if="firstLoading" class="gxb-loading" src="/public/images/loding.gif" alt="">
      <ul class="record-list">
        <li class="border-b" v-for="item in getRecord.list">
          <div class="p-info">
            <div class="p-type">
              <span v-if="item.rType===1">微信</span>
              <span v-if="item.rType===2">支付宝</span>
              <span v-if="item.rType===3">线下充值</span>
            </div>
            <div class="p-price">¥{{item.rMoney}} <span v-if="item.rReward">+¥{{item.rReward}}</span> </div>
          </div>
          <div class="p-date">
            {{item.changeDate}}
          </div>
        </li>
      </ul>
      <img v-if="firstLoading" class="gxb-loading" src="/public/images/loding.gif" alt="">
      <div v-if="getRecord.pageNum>getRecord.page">
        <div class="list-loading"v-if="loading" >
          <img src="/public/images/loading-min.gif" alt="">
        </div>
        <div class="list-loadmore" >
          <button class="loadmore-btn" @click="loadMore">
            加载更多
          </button>
        </div>
      </div>
      <div class="list-complete" v-if="getRecord.pageNum!=0 && (getRecord.pageNum<=getRecord.page)">
        <img src="/public/images/min-logo.png" alt="">
      </div>
    </div>
  </div>
</template>

<script lang="babel">
  import {mapGetters} from 'vuex'
  import gogaHeader from '@components/goga-header'
  import Icon from '@components/icon'

  const fetchRecordData = async function (store, page) {
    await store.dispatch('backend/management/getRecord', page)
  }
  export default {
    components: {
      gogaHeader,
      Icon
    },
    data() {
      return {
        firstLoading: true,
        loading: false
      }
    },
    computed: {
      ...mapGetters({
        getRecord: 'backend/management/getRecord'
      })
    },
    async mounted() {
      await  fetchRecordData(this.$store, 1);
      this.firstLoading = false
    },
    methods: {
      goBack() {
        this.$router.go(-1);
      },
      loadMore() {
        let page = this.jifen.page + 1;
        if(page <= this.jifen.pageNum) {
          this.loading = true;
          fetchRecordData(this.$store, page);
          this.loading = false;
        }
      }
    }
  }
</script>
<style lang="less">
  @import "index.less";
</style>
